<template>
 <div>
    <h1>登录</h1>
    <el-divider></el-divider>
    <el-form  label-width="auto" style="max-width: 600px">
        <el-form-item label="用户名">
           <el-input v-model="loginName" />
        </el-form-item>
        <el-form-item label="密码">
           <el-input type="password" v-model="loginPwd" />
        </el-form-item>
       <el-form-item>
           <el-button type="primary" @click="login">登录</el-button>
           <el-button>取消</el-button>
        </el-form-item>
  </el-form>

  </div>
</template>

<script>
import axios from 'axios';
import {ref,reactive} from 'vue';
import {userRouter} from 'vue-router';
export default { 
setup(){
   const loginName=ref('');
   const loginPwd=ref('');
   const a=ref(10);
   const router=userRouter();
const login=async ()=>{
      let resp=await axios.post("http://localhost:9090/my/ajax/login"
           ,"loginName="+loginName.value+"&loginPwd="+loginPwd.value)
        
      alert(resp.data.msg);
      if(resp.data.state==2000){
         router.push("/home");
      }
 } 
  

   // const login=function(){
   //      axios.post("http://localhost:9090/my/ajax/login"
   //         ,"loginName="+loginName.value+"&loginPwd="+loginPwd.value)
   //      .then((resp)=>{
   //             alert(resp.data.msg);
   //      });
   //    }
   return{
      loginName,
      loginPwd,
      login
   }
}
}

</script>


<style>

</style>